package demo.DataStrucAndAlgo.Easy_pritice;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/10/15-10-15-20:36
 * @Description：demo.DataStrucAndAlgo.Easy_pritice
 */
public class AntTest1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] nums = new int[n];

        long sum = 0;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            int j = 0;
            for(j = i; j > 0; j--){
                nums[j] = nums[j-1];
                if(num > nums[j-1]){
                    sum = sum + nums[j-1];
                    sum = sum % 1000000007;
                }else{
                    break;
                }

            }
            nums[j] = num;
        }
        System.out.println(sum);
    }
}
